const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
    entry: path.join(__dirname, './src/main.js'),
    output: {
        path: path.join(__dirname, './dist'),
        filename: 'bundle.js'
    },
    mode: 'development',
    plugins: [
        new htmlWebpackPlugin({
            template: path.join(__dirname, './src/index.html'),
            filename: 'index.html'
        }),
        new VueLoaderPlugin(),
    ],
    module: {
        rules: [
            { test: /\.css$/, use: ['style-loader', 'css-loader'] },
            { test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
            //name=[name].[ext]' 不改变名字和后缀名 [hash:8] 在前面添加一个八位的哈希值 这样名字相同的图片就不会被覆盖
            { test: /\.(jpg|png|bmp|gif|jpeg)$/, use: 'url-loader?limit=50000&name=[hash:8]-[name].[ext]' },
            //处理字体文件loader
            { test: /\.(ttf|eot|svg|woff|woff2)$/, use: 'url-loader' },
            // babel配置
            {
                test: /\.m?js$/,
                //exclude ：排除
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                        plugins: [
                            '@babel/plugin-proposal-object-rest-spread',
                            '@babel/plugin-proposal-class-properties'
                        ]
                    }
                }
            },
            {test:/\.vue$/,use: 'vue-loader'}
        ]
    },
    // resolve:{
    //     alias:{//Vue被导入时候的包的路径
    //         "vue$":"vue/dist/vue.js"
    //     }
    // }
}